package com._5704.website.controller;

import com._5704.website.exception.WebsiteException;
import com._5704.website.exception.WebsiteExceptionEnum;
import com._5704.website.util.JsonUtil;
import com._5704.website.vo.JsonVO;
import lombok.extern.log4j.Log4j2;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Log4j2
public class UnauthorizedController {
    /**
     * 被跳转页面
     * @return
     */
    @RequestMapping( "/unauthorized")
    public void unauthorized(){
        throw new WebsiteException(WebsiteExceptionEnum.TOKEN_ERROR);
    }

    @RequiresRoles("user")
    @GetMapping("/hello")
    public JsonVO hello(){
        return JsonUtil.success("hello");
    }
}
